#pragma once

#include <stack>

#include "planner/optimizer_task.h"

namespace optimizer {

class OptimizerTaskStack {
 public:
  OptimizerTask *Pop() {
    // ownership handed off to caller
    auto *task = task_stack_.top();
    task_stack_.pop();
    return task;
  }

  /**
   * Destructor for OptimizerTaskStack
   */
  ~OptimizerTaskStack() {
    while (!task_stack_.empty()) {
      auto *task = task_stack_.top();
      task_stack_.pop();
      delete task;
    }
  }

  void Push(OptimizerTask *task) {
    // ownership trasnferred to stack
    task_stack_.push(task);
  }

  bool Empty() { return task_stack_.empty(); }

 private:
  std::stack<OptimizerTask *> task_stack_;
};

}  // namespace optimizer
